<%@ page isELIgnored="false" contentType="text/html;charset=UTF-8" %>

<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="kr.co.amail.ems.init.Param" %>
<%@ page import="kr.co.amail.common.util.Cal" %>

<%@ page import="kr.co.amail.ems.init.Param" %>

<c:set var="f" value="${AutoAnylPoll0Form}"/>

<html>
<head>
<title><%=Param.get("title")%></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Cache-Control" content="no-cache"/> <meta http-equiv="Expires" content="0"/>
<link href="<%=Param.get("img.path")%>/cs.css" rel="stylesheet" type="text/css">

<link href="<%=Param.get("img.path")%>/wt_cs.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="<%=Param.get("servlet.path")%>/yui/build/button/assets/skins/sam/button.css" />
<link type="text/css" rel="stylesheet" href="<%=Param.get("servlet.path")%>/yui/build/datatable/assets/skins/sam/datatable.css">
<link rel="stylesheet" type="text/css" href="<%=Param.get("servlet.path")%>/yui/build/paginator/assets/skins/sam/paginator.css">
<link rel="stylesheet" type="text/css" href="<%=Param.get("servlet.path")%>/yui/build/tabview/assets/skins/sam/tabview.css" />

<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/yuiloader/yuiloader-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/dom/dom-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/event/event-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/json/json-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/element/element-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/swf/swf-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/charts/charts-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/button/button-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/datasource/datasource-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/connection/connection-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/get/get-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/dragdrop/dragdrop-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/calendar/calendar-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/datatable/datatable-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/paginator/paginator-min.js"></script>
<script type="text/javascript" src="<%=Param.get("servlet.path")%>/yui/build/tabview/tabview-min.js"></script>

<Script language="JavaScript" src="<%=Param.get("jsp.path")%>/inc/common.js"></Script>
<Script language="JavaScript" src="<%=Param.get("jsp.path")%>/inc/Calendar.js"></Script>
<script language="JavaScript" type="text/JavaScript">
//YUI 관련 설정값
YAHOO.widget.Chart.SWFURL = "<%=Param.get("servlet.path")%>/yui/build/charts/assets/charts.swf";

//차트내 Y축 설정 (00,000)
YAHOO.example.formatCurrencyAxisLabel = function( value )   
{   
    return YAHOO.util.Number.format( value,   
    {   
        decimalPlaces:1//thousandsSeparator: ","
    });   
}   
var yAxis = new YAHOO.widget.NumericAxis();
yAxis.labelFunction = YAHOO.example.formatCurrencyAxisLabel;
yAxis.minimum = 0;yAxis.maximum = 5;


YAHOO.example.getDataTipText = function(item, index, series) {
	//var toolTipText = item.StrValue + " : " + item.AvgValue;
	var toolTipText = item.AvgStr + "(응답건수 : " + item.Cnt +")";
	return toolTipText;
}


// 범례 style
var legendStyle = {
	padding: 5,
	legend:
	{
		display: "bottom",
		padding: 10,
		spacing: 5,
		font:
		{
			family: "돋움",
			size: 12
		}
	}
};



function init(){

	document.getElementById('start_yyyy').value = '<bean:write name="AutoAnylPoll0Form" property="start_yyyy"/>';
	document.getElementById('start_mm').value = '<bean:write name="AutoAnylPoll0Form" property="start_mm"/>';
	document.getElementById('start_dd').value = '<bean:write name="AutoAnylPoll0Form" property="start_dd"/>';
	
	document.getElementById('end_yyyy').value = '<bean:write name="AutoAnylPoll0Form" property="end_yyyy"/>';
	document.getElementById('end_mm').value = '<bean:write name="AutoAnylPoll0Form" property="end_mm"/>';
	document.getElementById('end_dd').value  = '<bean:write name="AutoAnylPoll0Form" property="end_dd"/>';


	<%
		String chart_info = (String) request.getAttribute("chart_info");
	%>
	try {
		var chart_info = '<%=chart_info%>';
		if (chart_info.replace(/(^\s*)|(\s*$)/g,"") == "") {
			document.getElementById('chart_all').innerHTML = "<h5>조회된 데이터 없음.";
			document.getElementById('chart_desc').style.display = "none";
		}
		else {
			res_data = YAHOO.lang.JSON.parse(chart_info);
			var chartData = new YAHOO.util.DataSource (res_data);
			//chartData.responseType = YAHOO.util.DataSource.TYPE_JSON;
			chartData.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
			chartData.responseSchema =
			{
				fields: ["Workday","AvgStr","Cnt","AvgValue"]
			};
			var seriesDef = [
			                 {displayName: "응답통계", yField: "AvgValue"}                 
			             	];

			var chart_all = new YAHOO.widget.LineChart( "chart_all", chartData,
			{
				xField: "Workday",
				series: seriesDef,
				yAxis: yAxis,
				//style: legendStyle,
				wmode : "transparent",
				dataTipFunction : YAHOO.example.getDataTipText,
				expressInstall: "<%=Param.get("servlet.path")%>/htdocs/js/yui/examples/charts/assets/expressinstall.swf"
			});
		}
		
	}
	catch (c) {
		alert(c.toString());
		return;
	}	
}

function checkSearch() {
	document.forms[0].submit();
}

function clear_postInfo(){
	document.forms[0].mail_type.value = "";
	document.forms[0].mail_type_seq.value = "";
	document.forms[0].channel_code.value = "";
	document.forms[0].mail_type_desc.value = "";
}

function setPostid(post_id){
	document.forms[0].post_id.value = post_id ;
}
function setSubject(subject){
	document.forms[0].subject.value = subject ;
}

function listDown(workday, ans) {
	var url = "<%=Param.get("servlet.path")%>/AutoPollListDown.do?workday="+workday+"&ans="+ans;
	document.forms[0].action = url;
	document.forms[0].submit();
}

function down2Xl() {
	var startdate = <%=(String) request.getAttribute("startdate")%>;
	var enddate = <%=(String) request.getAttribute("enddate")%>;
	var url = "<%=Param.get("servlet.path")%>/AutoPollDown2XL.do?startdate="+startdate+"&enddate="+enddate;
	document.forms[0].action = url;
	document.forms[0].submit();
}

function goPage(page) {
	document.forms[0].page.value = page;
	document.forms[0].submit();
}
</script>
</head>

<body class="yui-skin-sam" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="init()">
<html:form action="/AutoAnylPoll" >
<html:hidden name="AutoAnylPoll0Form" property="mail_type" />
<html:hidden name="AutoAnylPoll0Form" property="mail_type_seq" />
<html:hidden name="AutoAnylPoll0Form" property="channel_code" />
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<%@ include file="inc/Top.jsp" %>
<input type="hidden" name="imgUrl" value="<%=Param.get("img.path")%>">
  <tr> 
<%@ include file="inc/LeftMenu.jsp" %>
<td width="100%" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr> 
                <td>
                <%@ include file="inc/6_0_AmailMenuHistory.jsp" %>

	              <table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF">
                    <tr> 
                      <td><img src="<%=Param.get("img.path")%>/sp.gif" width="5" height="5"></td>
                    </tr>
                  </table>
  

					<div class="sub_title2" >
						<img src="<%=Param.get("img.path")%>/title_icon_arw.gif" align="absmiddle"/> 자동메일 설문분석
						<span class="sub_title_description">&nbsp;설문이 들어있는 자동 메일에 대한 추이를 확인할 수 있다.</span>
					</div>
					
					
					<div class="sub_area_1"><div class="sub_area_2">
						<table border="0" cellspacing="0" cellpadding="1">	
							<tr>
								<td>
									<label>검색 기준</label>
									<img style="margin-right: 10px;" src="<%=Param.get("img.path")%>/f_line_01.gif" align="absmiddle"/>
	          						<html:text name="AutoAnylPoll0Form" property="mail_type_desc" styleClass="inputl" size="40"  readonly="true" style="width:322" onkeydown="RemoveBackSpaceEvent()"/>
	          						
	          						<a href=# onClick="javascript:launchCenter('AutoCommMailFindPop.do','AutoCommMailFindPop',300,420,'')"><img src="<%=Param.get("img.path")%>/btn_search.gif" border="0" align="absmiddle" /></a>
								            <a href="javascript:clear_postInfo()"><img src="<%=Param.get("img.path")%>/btn_icon2_03.gif" border="0" width="100" height="21" align="absmiddle"></a>									 
								</td>
							</tr>
					
							<tr><td bgcolor="#e5e6e8" height="1"></td></tr>
							
							<tr style="display:none"><td bgcolor="#e5e6e8" height="1"></td></tr>
					
							<tr>
								<td>
								<label>기간</label>
									<img style="margin-right: 10px;" src="<%=Param.get("img.path")%>/f_line_01.gif" align="absmiddle"/>
									<input type="text" name="start_yyyy" size="4" maxlength="4" readonly="true" onkeydown="RemoveBackSpaceEvent()"/>
									<input type="text" name="start_mm" size="2" maxlength="2" readonly="true" onkeydown="RemoveBackSpaceEvent()"/>
									<input type="text" name="start_dd" size="2" maxlength="2" readonly="true" onkeydown="RemoveBackSpaceEvent()"/>
									<img src="<%=Param.get("img.path")%>/btn_day.gif" border="0" width="69" height="21" onClick="ShowCalendar('<%=Cal.getSerialDate()%>','start_yyyy','start_mm','start_dd');" align="absmiddle">
									&nbsp;~&nbsp;
									<input type="text" name="end_yyyy" size="4" maxlength="4" readonly="true" onkeydown="RemoveBackSpaceEvent()"/>
									<input type="text" name="end_mm" size="2" maxlength="2" readonly="true" onkeydown="RemoveBackSpaceEvent()"/>
									<input type="text" name="end_dd" size="2" maxlength="2" readonly="true" onkeydown="RemoveBackSpaceEvent()"/> 
									<img src="<%=Param.get("img.path")%>/btn_day.gif" border="0" width="69" height="21" onClick="ShowCalendar('<%=Cal.getSerialDate()%>','end_yyyy','end_mm','end_dd');" align="absmiddle">
									<!-- <a href="javascript:document.forms[0].submit();"> -->
									<a href="javascript:checkSearch();"> 
									<img src="<%=Param.get("img.path")%>/btn_icon_14.gif" border="0" align="absmiddle"/>
									</a>
									</td>
							</tr>
						</table>
					</div></div>
					
                  <div class="sub_title">설문응답 추이</div>
                  <div class="sub_area_1"><div class="sub_area_2">
                  <table width="100%" border="0">
                  	<tr>
                  		<td width="7%" id="chart_desc" valign="top">
                  			<br><br>
                  			<table width="100%" border="0">
                  				<tr height="57px"><td align="center">매우나쁨<br>4.0~5.0</td></tr>
                  				<tr height="57px"><td align="center">나쁨<br>3.0~4.0</td></tr>
                  				<tr height="57px"><td align="center">보통<br>2.0~3.0</td></tr>
                  				<tr height="57px"><td align="center">좋음<br>1.0~2.0</td></tr>
                  				<tr height="57px"><td align="center">매우좋음<br>0.0~1.0</td></tr>
                  			</table>                  			
                  		</td>
                  		<td width="93%">
                  			<div class="chart" id="chart_all" align="center"></div>
                  		</td>
                  	</tr>
                  </table>
                  </div>
                  </div>

				  <!-- 다운로드 -->
                  <div class="sub_title">상세 보기 <a href=# onclick="javascript:down2Xl()"><img src="./img/excel_img.jpg" width="25px" height="25px"></a></div>
                  <div class="sub_area_1"><div class="sub_area_2">

					<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="afb0b2">
						<tr> 
	                      <td width="10%" height = "25" bgcolor="#FFFFFF" class="table_t_01"><div align="center">WORKDAY</div></td>
	                      <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">평균</div></td>
	                      <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">점수</div></td>
						  <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">건수</div></td>	                      
	                      <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">매우좋음</div></td>
	                      <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">좋음</div></td>
	                      <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">보통</div></td>
	                      <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">나쁨</div></td>
						  <td width="10%" bgcolor="#FFFFFF" class="table_t_01"><div align="center">매우나쁨</div></td>
	                    </tr>
		          		<tr>
							<td height="2" colspan="16" bgcolor="666666"></td>
						</tr>					
					
						 <% int idx = 1; %>
	                  <logic:iterate id="list" name="result">
						<%++idx;%>
	                    <tr> 
	                      <td  bgcolor="fbfbfb" height="25" bgcolor="<%=(idx%2==0)?"#F6F6F6":"#DFECF6"%>">
	                      	<div align="center"><bean:write name="list" property="workday"/></div>
	                      </td>
	                      <td  bgcolor="fbfbfb" >
	                      	<div align="center"><bean:write name="list" property="avg_value"/></div>
						  </td>
	                      <td bgcolor="fbfbfb" >
	                      	<div align="center"><bean:write name="list" property="avg_str"/></div>
	                      </td>
						  <td bgcolor="fbfbfb" >
	                      	<div align="center"><bean:write name="list" property="cnt"/></div>
	                      </td>	                      
	                      <td bgcolor="fbfbfb" >
	                      	<div align="center"><a href="javascript:listDown('<bean:write name="list" property="workday"/>', '1')"><bean:write name="list" property="val_1"/></a></div>
	                      </td>
	                      <td bgcolor="fbfbfb" >
	                      	<div align="center"><a href="javascript:listDown('<bean:write name="list" property="workday"/>', '2')"><bean:write name="list" property="val_2"/></a></div>
	                      </td>
	                      <td bgcolor="fbfbfb" >
	                      	<div align="center"><a href="javascript:listDown('<bean:write name="list" property="workday"/>', '3')"><bean:write name="list" property="val_3"/></a></div>
	                      </td>
	                      <td bgcolor="fbfbfb" >
	                      	<div align="center"><a href="javascript:listDown('<bean:write name="list" property="workday"/>', '4')"><bean:write name="list" property="val_4"/></a></div>
	                      </td>
	                      <td bgcolor="fbfbfb" >
	                      	<div align="center"><a href="javascript:listDown('<bean:write name="list" property="workday"/>', '5')"><bean:write name="list" property="val_5"/></a></div>
	                      </td>
	                    </tr>
	                  </logic:iterate>
						<% if ( idx == 1 ) { %>
	                    
	                    <tr class="content"> 
	                      <td  bgcolor="fbfbfb" colspan="9" height="25"><div align="center">리스트가 존재하지 않습니다.</div></td>
	                    </tr>
	                  <% } %>
	                  </table>
					  <br/>
	                  <div class="result_page">
                             <!-- paging start -->
                             <html:hidden property="page"/>
                             <html:hidden property="rows"/>
                             <logic:notEqual name="pageObject" property="totalCnt" scope="request" value="0">
                              <div align="center">
                              
                                	<bean:define id="previousPage" name="pageObject" property="previousPage" type="java.lang.Integer"/>
                                	<a href="javascript:goPage('<%=previousPage%>')"><img class="img_middle" src="<%=Param.get("img.path")%>/arrow_01.gif" width="13" height="12"></a>
                                
                                <logic:equal name="pageObject" property="hasPrevious" scope="request" value="true">
                                </logic:equal>
                              
                                <span class="content">
                                	
                                	<% idx = 0; %>
                                  <logic:iterate id="pageList" name="pageObject" property="currentPageList">
                                   
                                    <bean:define id="c_page" name="pageList" type="java.lang.String"/>
                                    
                                    <logic:notEqual name="AutoAnylPoll0Form" property="page" value="<%=c_page%>">
	                                    <%if(idx == 0){%>
	                                    <%}else{%>
	                                    |                                   
	                                    <%}%>
	                                    <a href="javascript:goPage('<bean:write name="pageList" />')">
	                                      <bean:write name="pageList" />
	                                    </a> 
                                    </logic:notEqual>
                                    <logic:equal name="AutoAnylPoll0Form" property="page" value="<%=c_page%>">
	                                    <strong><bean:write name="pageList" /></strong> 
                                    </logic:equal>
                                  <% ++idx; %>
                                  </logic:iterate>
                                </span>
                                	<bean:define id="nextPage" name="pageObject" property="nextPage" type="java.lang.Integer"/>
                                	<a href="javascript:goPage('<%=nextPage%>')"><img class="img_middle" src="<%=Param.get("img.path")%>/arrow_02.gif" width="13" height="12"></a>
                                <logic:equal name="pageObject" property="hasNext" scope="request" value="true">
                                </logic:equal>
                              </div>
                             </logic:notEqual>
                             <!-- paging end -->
	                  </div>                     
                  </div>
                  </div>                 
                  
              </td>             
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td colspan="4"><img src="<%=Param.get("img.path")%>/sp.gif" width="5" height="20"></td>
  </tr>
  <tr> 
    <td colspan="4"><table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr> 
          <td width="12"><img src="<%=Param.get("img.path")%>/sp.gif" width="12" height="5"></td>
          <td>&nbsp;</td>
          <td width="12"><img src="<%=Param.get("img.path")%>/sp.gif" width="12" height="5"></td>
        </tr>
      </table></td>
  </tr>
</table>
</html:form>

<script type="text/javascript">

</script>

</body>
</html>
